package cz.muni.fi.pb138.avradiation.web;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author huzvak
 */
public class Location implements Comparable<Object> {
    
    private Long id = null;
    private String name = null;

    public Location() {
    }

    public Location(Long id, String name) {
        this.id = id;
        this.name = name;
    }

    public Long getId() {
        return id;
    }

    public String getName() {
        return name;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Location other = (Location) obj;
        if (this.id != other.id && (this.id == null || !this.id.equals(other.id))) {
            return false;
        }
        if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 97 * hash + (this.id != null ? this.id.hashCode() : 0);
        return hash;
    }

    @Override
    public String toString() {
        return "Location{" + "id=" + id + ", name=" + name + '}';
    }

    @Override
    public int compareTo(Object t) {
        Location l = (Location) t;
        
        int out = 0;
        if ((name != null) && (out = name.compareTo(l.getName())) != 0) {
            return out;
        }
        
        if ((id != null) && (out = id.compareTo(l.getId())) != 0) {
            return out;
        }
        
        return out;
    }
}
